"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_police_index = require("../../../api/police/index.js");
const config_app = require("../../../config/app.js");
const stores_userInfo = require("../../../stores/userInfo.js");
if (!Array) {
  const _easycom_up_avatar2 = common_vendor.resolveComponent("up-avatar");
  const _easycom_up_checkbox2 = common_vendor.resolveComponent("up-checkbox");
  const _easycom_up_cell2 = common_vendor.resolveComponent("up-cell");
  const _easycom_up_list_item2 = common_vendor.resolveComponent("up-list-item");
  const _easycom_up_checkbox_group2 = common_vendor.resolveComponent("up-checkbox-group");
  const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  const _easycom_up_list2 = common_vendor.resolveComponent("up-list");
  const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
  (_easycom_up_avatar2 + _easycom_up_checkbox2 + _easycom_up_cell2 + _easycom_up_list_item2 + _easycom_up_checkbox_group2 + _easycom_up_empty2 + _easycom_up_list2 + _easycom_up_toast2)();
}
const _easycom_up_avatar = () => "../../../node-modules/uview-plus/components/u-avatar/u-avatar.js";
const _easycom_up_checkbox = () => "../../../node-modules/uview-plus/components/u-checkbox/u-checkbox.js";
const _easycom_up_cell = () => "../../../node-modules/uview-plus/components/u-cell/u-cell.js";
const _easycom_up_list_item = () => "../../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
const _easycom_up_checkbox_group = () => "../../../node-modules/uview-plus/components/u-checkbox-group/u-checkbox-group.js";
const _easycom_up_empty = () => "../../../node-modules/uview-plus/components/u-empty/u-empty.js";
const _easycom_up_list = () => "../../../node-modules/uview-plus/components/u-list/u-list.js";
const _easycom_up_toast = () => "../../../node-modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
  (_easycom_up_avatar + _easycom_up_checkbox + _easycom_up_cell + _easycom_up_list_item + _easycom_up_checkbox_group + _easycom_up_empty + _easycom_up_list + _easycom_up_toast)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "selectUser",
  setup(__props) {
    const userInfoStore = stores_userInfo.useUserInfoStore();
    const uToastRef = common_vendor.ref(null);
    const selectUserIds = common_vendor.ref([]);
    const list = common_vendor.ref([]);
    common_vendor.onLoad((options) => {
      if (options && options.users) {
        selectUserIds.value = options.users.split(",").map(Number);
      }
      getPoliceList();
    });
    const scrolltolower = () => {
      loadmore();
    };
    const loadmore = () => {
      console.log("加载更多");
    };
    const getPoliceList = () => {
      common_vendor.index.showLoading({
        title: "加载中",
        mask: true
      });
      api_police_index.policeListByCommunityId({ communityId: userInfoStore.crowdInfo.communityId }).then((res) => {
        common_vendor.index.hideLoading();
        const { data } = res;
        list.value = data ?? [];
      }).catch((err) => {
        common_vendor.index.hideLoading();
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const onsubmit = () => {
      if (selectUserIds.value.length) {
        let policeUsers = [];
        list.value.forEach((item) => {
          if (selectUserIds.value.indexOf(item.policeUserId) != -1) {
            policeUsers.push(item.userName + " " + item.badgeNumber);
          }
        });
        common_vendor.index.$emit("updateServiceUser", {
          selectUserIds: selectUserIds.value,
          policeUsers
        });
        common_vendor.index.navigateBack({
          delta: 1
        });
      } else {
        uToastRef.value.show({
          type: "warning",
          message: "请选择对象"
        });
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.unref(list).length
      }, common_vendor.unref(list).length ? {
        b: common_vendor.f(common_vendor.unref(list), (item, index, i0) => {
          return {
            a: "8953986a-4-" + i0 + "," + ("8953986a-3-" + i0),
            b: common_vendor.p({
              shape: "circle",
              size: "42",
              src: common_vendor.unref(config_app.imgPrefix) + item.avatar
            }),
            c: common_vendor.t(item.userName),
            d: common_vendor.t(item.badgeNumber),
            e: "8953986a-5-" + i0 + "," + ("8953986a-3-" + i0),
            f: common_vendor.p({
              activeColor: "#0189FE",
              name: item.policeUserId,
              shape: "circle"
            }),
            g: "8953986a-3-" + i0 + "," + ("8953986a-2-" + i0),
            h: index,
            i: "8953986a-2-" + i0 + ",8953986a-1"
          };
        }),
        c: common_vendor.o(($event) => common_vendor.isRef(selectUserIds) ? selectUserIds.value = $event : null),
        d: common_vendor.p({
          placement: "column",
          modelValue: common_vendor.unref(selectUserIds)
        })
      } : {
        e: common_vendor.p({
          mode: "history",
          text: "该社区暂无民警",
          icon: "http://cdn.uviewui.com/uview/empty/history.png"
        })
      }, {
        f: common_vendor.o(scrolltolower),
        g: common_vendor.p({
          height: "calc(100vh - 64rpx - 83rpx - 20rpx)"
        }),
        h: common_vendor.o(onsubmit),
        i: common_vendor.sr(uToastRef, "8953986a-7", {
          "k": "uToastRef"
        })
      });
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8953986a"]]);
wx.createPage(MiniProgramPage);
